package de.gbeine.java.depview.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

import org.springframework.beans.factory.annotation.Required;

import com.google.common.eventbus.EventBus;


/**
 *
 * @author gbeine
 *
 */
public final class MainWindow {

    /**
     *
     */
    private JFrame frmDependencyviewer;
    /**
     *
     */
    private JMenuBar menuBar;
    /**
     *
     */
    private EventBus eventBus;

    /**
     * Create the application.
     */
    public MainWindow(final EventBus pEventBus) {
        this.eventBus = pEventBus;
        initialize();
    }

    /**
     *
     */
    public void init() {
        this.frmDependencyviewer.setVisible(true);
    }

    /**
     *
     * @param pContentPanel
     */
    @Required
    public void setContentPanel(final JPanel pContentPanel) {
        this.frmDependencyviewer.getContentPane().add(pContentPanel, BorderLayout.CENTER);
    }

    /**
     *
     * @param pStatusPanel
     */
    @Required
    public void setStatusPanel(final JPanel pStatusPanel) {
        this.frmDependencyviewer.getContentPane().add(pStatusPanel, BorderLayout.SOUTH);
    }

    /**
     *
     * @param pMenu
     */
    public void setMainMenu(List<JMenu> pMenu) {
        for (JMenu jMenu : pMenu) {
            this.menuBar.add(jMenu);
        }
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        this.menuBar = new JMenuBar();

        this.frmDependencyviewer = new JFrame();
        this.frmDependencyviewer.setTitle("DependencyViewer");
        this.frmDependencyviewer.setBounds(100, 100, 455, 560);
        this.frmDependencyviewer.setJMenuBar(this.menuBar);
        this.frmDependencyviewer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.frmDependencyviewer.getContentPane().setLayout(new BorderLayout(0, 1));
    }

}
